<template>
    <div class='myselect' :style="styles">
        <el-select  ref="mySelect"  @focus="selectClick" v-if="isApp=='Y'&&selectType==''" :id="id" :class="classs"  v-model.lazy="currentValue" placeholder="请选择"  :style="{'width':'100%','position':isEdit=='Y' ? 'absolute':'','fontSize':fontSize=='' ? '14px':fontSize}"  :disabled="disabled">
            <el-option
            v-for="(item,index) in optionnews"
            :key="index"
            :label="item.optname"
            size="small"
            :value="item.optvalue">
            </el-option>
        </el-select>
        <el-select ref="mySelect"   @focus="selectClick"  filterable v-if="isApp!='Y'&&selectType==''" :id="id" :class="classs"  v-model="currentValue" placeholder="请选择" class='myselect' :style="{'width':'100%','position':isEdit=='Y' ? 'absolute':'','fontSize':fontSize=='' ? '14px':fontSize}"  :disabled="disabled">
            <el-option
            v-for="(item,index) in optionnews"
            :key="index"
            :label="item.optname"
            size="small"
            :value="item.optvalue">
            </el-option>
        </el-select>

        <el-autocomplete
        ref="myInput"
        class="inline-input"
        :required="isRequired"
        v-model="currentValue"
        :id="id"
        :fetch-suggestions="querySearch"
        :class='{"myInput":true,"isEdits":isEdit=="Y" ? true:false}' :style="styles" clearable size="small" v-if="isEdit=='Y'"
        :trigger-on-focus="true"
        
        ></el-autocomplete>

        <!--el-input ref="myInput"  v-model="currentValue" placeholder=""  :required="isRequired" :id="id" :class='{"myInput":true,"isEdits":isEdit=="Y" ? true:false}' :style="styles" clearable size="small" v-if="isEdit=='Y'"> </el-input-->
        <template v-if="selectType=='radio'">
            <template v-for="(item,index) in optionnews">
                <el-radio v-model="currentValue" :label="item.optvalue"  v-if="item.optname!='请选择...'"   :key="index" border>{{item.optname}}</el-radio>
            </template>
            
        </template>
        <template v-if="selectType=='cascader'">
            <el-cascader
                ref="myInputs"
                clearable
                filterable
                @change="handleChange"
                :show-all-levels="false"
                v-model="currentValue2"
                :options="optionnew2"
                ></el-cascader>
        </template>
    </div>
   
</template>
 
<script>
   
   import filterXSS from "xss"
    export default {
        props:['id','options','isAudio','styles','value','data','selectData','index','isreadonly','isBorder','extype','valsql','appid','dataField','isSearch','isChange','exkey','sign','time','sign2','time2','postUrl','isEdit','valsql2','fontSize','isRequired'],
        //props:["data","index","appid","dataField","attribute","isBorder"],
        name: "input-select",
        data(){
            return {
                currentValue:'',
                currentValue2:'',
                currentValue3:'',
                disabled:false,
                currentValueOld:'',
                classs:'',
                first:'Y',
                pId:"",
                cId:"",
                disableds2:"",
                isApp:sessionStorage.getItem("isApp"),
                changeId:{},
                optionnews:[],
                oldValue:"",
                dataSource:"",
                styleNew:this.styles,
                xssOption:{
                    stripIgnoreTagBody:true
                },
                isreadonlys:"N",
                isDefaultSelect:"N",
                paramKey:"",
                setDatas:[],
                sessionKey:"",
                sessionField:{},
                sessionSelect:"",
                getSession:null,
                sessionStr:"",
                selectType:"",
                isHasGetAudio:"N",
                optionnew2:[],
                amtStr:""
               /* id:"",
                value:"",
                styles:"",
                options:"",
                isreadonly:"",
                extype:"",
                valsql:"",
                isSearch:"",
                isChange:"",
                exkey:"",
                sign:"",
                time:"",
                sign2:"",
                time2:"",
                postUrl:"",
                isEdit:"",
                valsql2:""*/

            }
        },
        created(){
            
            try{
                if(this.exkey&&this.exkey.setData)
                    this.setDatas=this.exkey.setData;
            }catch(e){}
            try{
                if(this.exkey&&this.exkey.sessionKey)
                    this.sessionKey=this.exkey.sessionKey;
            }catch(e){}
            try{
                if(this.exkey&&this.exkey.sessionField)
                    this.sessionField=this.exkey.sessionField;
            }catch(e){}
            try{
                if(this.exkey&&this.exkey.sessionSelect)
                    this.sessionSelect=this.exkey.sessionSelect;
            }catch(e){}
            try{
                if(this.exkey&&this.exkey.selectType){
                    this.selectType=this.exkey.selectType;
                }
            }catch(e){}
            if(this.options){
                this.optionnews=this.options
            }
             if(this.fontSize){
                let fontSize="font-size:"+this.fontSize+";";
                this.styleNew=fontSize+this.styleNew;
            }
            console.log("inputsleect============"+this.id+"==="+this.selectType)
            console.log(this.optionnews)
            if(this.isreadonly=="Y"){
               
            }
            try{
                this.isDefaultSelect=this.exkey.isDefaultSelect;
            }catch(e){}
            try{
                this.paramKey=this.exkey.paramKey;
            }catch(e){}
            try{
                if(this.exkey.amtStr){
                    this.amtStr=this.exkey.amtStr;
                }else{
                    this.amtStr=this.exkey;
                }
            }catch(e){}
          /*  if(this.attribute.id){
                this.id=this.attribute.id;
            }
            if(this.attribute.value){
                this.id=this.attribute.value;
            }
            
            if(this.attribute.styles){
                this.styles=this.attribute.styles;
            }
             if(this.attribute.options){
                this.options=this.attribute.options;
            }else if(this.attribute.dataSource){
                this.options=this.attribute.dataSource;
            } 
            if(this.attribute.isReadOnly){
                this.isreadonly=this.attribute.isReadOnly;
            }
           
            if(this.attribute.extype){
                this.extype=this.attribute.extype;
            }
            if(this.attribute.valsql){
                this.valsql=this.attribute.valsql;
            }
            if(this.attribute.isSearch){
                this.isSearch=this.attribute.isSearch;
            }
            if(this.attribute.isChange){
                this.isChange=this.attribute.isChange;
            }
             if(this.attribute.exkey){
                this.exkey=this.attribute.exkey;
            }

            if(this.attribute.isRequired){
                this.isRequired=this.attribute.isRequired;
            }
            
            if(this.attribute.sign){
                this.sign=this.attribute.sign;
            }
            if(this.attribute.time){
                this.time=this.attribute.time;
            }
            if(this.attribute.sign2){
                this.sign2=this.attribute.sign2;
            }
            if(this.attribute.time2){
                this.time2=this.attribute.time2;
            }

            if(this.attribute.postUrl){
                this.postUrl=this.attribute.postUrl;
            }

            if(this.attribute.isEdit){
                this.isEdit=this.attribute.isEdit;
            }

            if(this.attribute.valsql2){
                this.valsql2=this.attribute.valsql2;
            }
           */
            
            //alert(this.isEdit)

            if(this.isBorder=='N'){
                this.classs="no-border";
            }
            if(this.isEdit=="Y"){
                this.classs=this.classs+" isEdits"
            }
            if(this.sessionKey){
                this.getSession=window.setInterval(()=>{
                     if(sessionStorage.getItem(this.sessionKey+"load")=="Y"&&this.sessionStr!=sessionStorage.getItem(this.sessionKey)){
                        this.sessionStr=sessionStorage.getItem(this.sessionKey)
                        //sessionStorage.setItem(this.sessionKey+"load"+this.index,"N")
                        this.optionnews=[]
                        //clearInterval(getSession);
                        let option_=JSON.parse(sessionStorage.getItem(this.sessionKey));
                        if(option_.length>1000){
                            for(let i=0;i<1000;i++){
                                this.optionnews.push(option_[i])
                            }
                        }else{
                            this.optionnews=option_;
                        }
                        let optname=this.sessionField.optname;
                        let optvalue=this.sessionField.optvalue;
                        for(let i=0;i<this.optionnews.length;i++){
                            let optname_=optname;
                            let optvalue_=optvalue;
                            for(let key in this.optionnews[i]){
                                //if(key=="szi_ex1"){
                                    optname_=optname_.replace("#"+key+"#",this.optionnews[i][key])
                                    optvalue_=optvalue_.replace("#"+key+"#",this.optionnews[i][key])
                                  //  console.log("key==="+key+"=="+this.optionnews[i][key]+"=="+optname_+"="+optvalue_)
                                    
                                //}
                                
                            }
                            this.optionnews[i].optname=optname_;
                            this.optionnews[i].optvalue=optvalue_;
                        }
                        this.setData();
                        console.log(this.optionnews,"this.optionnews======")
                     }
                },500)
            }else{
                this.getSelect();
                this.setData();
            }
            
            
            

            try{
                if(this.exkey.readonlys){
                    let isReadonly_="Y"
                    for(let i=0;i<this.exkey.readonlys.length;i++){
                        let ids=this.exkey.readonlys[i].id.split(".");
                        
                        let opr=this.exkey.readonlys[i].opr;
                        let vals=this.exkey.readonlys[i].val;
                        let val_="";
                        if(ids[0]=="本身"){
                            val_=this.currentValue;
                        }else{
                            if(ids.length==2)
                                val_=this.data[ids[0]][ids[1]];
                            else
                                val_=this.data[this.pId][ids[0]]
                        }
                        if(val_==undefined){
                            val_="";
                        }
                        //console.log("vals==="+vals+"=="+val_+"=="+opr+"=="+ids[0]+"=="+this.currentValue)
                        if(opr=="等于"&&vals!=val_){
                            //this.isreadonlys="Y";
                            isReadonly_="N"
                        }
                        if(opr=="不等于"&&vals==val_){
                            //this.isreadonlys="Y";
                            isReadonly_="N"
                        }

                    }
                    this.isreadonlys=isReadonly_;
                }
            }catch(e){}

            if(this.isreadonly=='Y'||this.isreadonlys=="Y"){
                this.disabled=true;
                this.disableds2=true;
            }  
            //选择录音文件的回调
            window.setWebViewAudioList = this.setAudioList

        },
         mounted(){
           
            try{
                this.$refs.myInput.$parent.$parent.$children[0].$el.style.fontSize=this.fontSize
            }catch(e){}
             try{
                this.$refs.mySelect.$parent.$parent.$children[0].$el.style.fontSize=this.fontSize
            }catch(e){}
             try{
                this.$refs.mySelect.$children[0].$el.style.fontSize=this.fontSize
            }catch(e){}
             try{
                this.$refs.mySelect.$children[1].$el.style.fontSize=this.fontSize
            }catch(e){}
             try{
                let childrens=this.$refs.mySelect.$children[1].$children[0].$children;
                for(let i=0;i<childrens.length;i++){
                    childrens[i].$el.style.fontSize=this.fontSize
                }
            }catch(e){}
        },
        destroyed(){
            //console.log("烧毁inputselect")
            if(this.getSession){
                clearInterval(this.getSession)
            }
        },
        methods:{
            querySearch(queryString, cb){
                var restaurants = this.optionnews;
                var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
                console.log(results,"results22======================")
                results.forEach(item=>{
                    item.value=item.optvalue;
                })
                // 调用 callback 返回建议列表的数据
                cb(results);
            },
            createFilter(queryString) {
                return (restaurant) => {
                    return (restaurant.optname.toLowerCase().indexOf(queryString.toLowerCase())!=-1||restaurant.c_ex5.toLowerCase().indexOf(queryString.toLowerCase())!=-1||restaurant.c_ex6.toLowerCase().indexOf(queryString.toLowerCase())!=-1);
                };
            },
            setAudioList(data){
                //alert("data="+JSON.stringify(data))
                this.optionnews=data;
            },
            selectClick(){
                console.log("selectClick=========")
                
                try{
                    if(this.isAudio=="Y"&&(this.isHasGetAudio!="Y"||this.optionnews.length==0)){
                        this.myUni.webView.postMessage({  
                            data: {  
                                action: "getAudio",
                                path:this.exkey.audio.path
                            },  
                        });
                        this.isHasGetAudio="Y"
                    }
                }catch(e){}
                
            },
            getAudio(){
                
                try{
                    //if(this.isAudio=="Y"){
                        this.myUni.webView.postMessage({  
                            data: {  
                                action: "getAudio",
                                path:this.exkey.audio.path
                            },  
                        });
                    //}
                }catch(e){}
            },
            getSelect2(id){
                this.$post("api","/api/view/getSelectSql",{valsql:this.valsql2,sId:id,signs:this.sign2,times:this.time2}).then(data=>{
                    this.valsql=data.val;
                    this.sign=data.sign;
                    this.time=data.time;
                    this.getSelect();
                })
            },
            getSelect(){
                //alert(this.valsql)
                let idss=this.id.split(".");
                this.pId=idss[0]
                if(this.valsql){
                    let ids=this.id.split(".");
                    
                    let valsql=this.valsql.split("|");
                    let sql=valsql[0];
                    let oldSql=this.valsql;
                    this.changeId={};
                    for(let i=1;i<valsql.length;i++){
                        let id=valsql[i];
                        if(id.indexOf(".")==-1){
                            sql=sql.replace('##'+id+'##',this.data[ids[0]][id]);
                            while(sql.indexOf('##'+id+'##')!=-1){
                                sql=sql.replace('##'+id+'##',this.data[ids[0]][id]);
                            }
                            this.changeId[id]=this.data[ids[0]][id];//哪个字段改变会触发他重新读取
                        }else{
                            let ids_=valsql[i].split(".");
                            //alert(this.data[ids_[0]][ids_[1]])
                            sql=sql.replace('##'+ids_[1]+'##',this.data[ids_[0]][ids_[1]]);
                           // alert(sql+"="+ids_[0])
                            while(sql.indexOf('##'+ids_[1]+'##')!=-1){
                                sql=sql.replace('##'+ids_[1]+'##',this.data[ids_[0]][ids_[1]]);
                            }
                            this.changeId[ids_[1]]=this.data[ids_[0]][ids_[1]];//哪个字段改变会触发他重新读取
                        }
                        
                    }
                    let appid=this.appid;
                    if(!appid){
                        appid="business"
                    }
                    if(sql.indexOf("appid=")!=-1){
                        let sqls=sql.split("#");
                        sql=sqls[1];
                        appid=sqls[0];
                        appid=appid.replace("appid=","");
                    }
                    
                   
                    this.$postEncrypt(appid,"/api/common/getData",{
                        sql:sql,
                        oldSql:oldSql,
                        times:this.time,
                        sign:this.sign
                    }).then(data=>{
                       
                        if(this.selectType!="radio"){
                            let option={
                                optname:"请选择...",
                                optvalue:""
                            }
                            this.optionnews=[];
                            
                            if(data.length>0&&data[0].optname&&data[0].optname.indexOf("请选择")==-1){
                                this.optionnews.push(option);
                            }
                        }
                        
                        for(let i=0;i<data.length;i++){
                            if(!data[i].optvalue&&data[i].optname.indexOf("请选择")==-1){
                                data[i].optvalue=data[i].optname;
                            }
                            this.optionnews.push(data[i])
                        }
                        try{
                            this.$set("optionnews",this.optionnews);
                        }catch(e){}
                        
                         this.$emit("selectdata",JSON.stringify(data));
                    })
                }

                if(this.postUrl){
                    let paramData={}
                   // console.log(this.exkey.params,"params=====================ss==")
                    if(this.exkey&&this.exkey.params){
                        for(let key in this.exkey.params){
                            if(this.dataField){
                    
                                let data_=this.data[this.dataField][this.index];
                                paramData[key]=data_[this.exkey.params[key]]
                            }else{
                                if(this.index=="0"||this.index){
                                    

                                    paramData[key]=this.data[this.pId][this.index][this.exkey.params[key]]
                                }else{
                                    console.log("key===="+key+"=="+this.exkey.params[key]+"=="+this.pId);
                                    console.log(this.data)
                                    paramData[key]=this.data[this.pId][this.exkey.params[key]]
                                }
                                    
                                
                            }
                        }
                    }
                    this.$post("",this.postUrl,paramData).then(data=>{
                        if(this.selectType=='cascader'){
                            this.optionnew2=data;
                        }else{
                            let option={
                                optname:"请选择...",
                                optvalue:""
                            }
                            this.optionnews=[];
                        
                            if(data.length>0&&data[0].optname&&data[0].optname.indexOf("请选择")==-1){
                                this.optionnews.push(option);
                            }
                        
                            for(let i=0;i<data.length;i++){
                                if(!data[i].optvalue){
                                    data[i].optvalue=data[i].optname;
                                }
                                this.optionnews.push(data[i])
                            }
                        }
                        
                    })
                }
                if(this.exkey){
                   
                     try{
                        this.dataSource=this.exkey.dataSource;
                    }catch(e){}
                    let showField="";
                    try{
                        showField=this.exkey.showField;
                    }catch(e){}
                     try{
                        if(this.exkey.changeField&&!this.changeId[this.exkey.changeField]){
                            this.changeId[this.exkey.changeField]="";
                            try{
                                let pId=this.id.split(".")[0]
                               
                                if(this.dataField){
                                    this.changeId[this.exkey.changeField]=this.data[this.dataField][this.index][this.exkey.changeField]
                                }else{
                                    this.changeId[this.exkey.changeField]=this.data[pId][this.exkey.changeField]
                                }
                                
                            }catch(e){}
                           // alert(this.changeId[this.exkey.changeField])
                        }
                    }catch(e){}
                    
                    if(this.dataSource){
                        let isOkss=false;
                        if(this.exkey.changeField){
                            let optionss=this.selectData[this.dataSource];
                            let optionsss=[];
                            for(let i=0;i<optionss.length;i++){
                               //console.log("dataSource1============"+this.exkey.changeField+":=showField:"+showField+":"+this.dataSource+"+"+optionss[i][showField]+":"+this.changeId[this.exkey.changeField])
                               //根据其他字段值不同显示不同下拉框值 
                               if(optionss[i][showField]==this.changeId[this.exkey.changeField]&&this.changeId[this.exkey.changeField]){
                                    optionsss.push(optionss[i])

                                    if(optionss[i.optvalue==this.currentValue]){
                                        isOkss=true;
                                    }
                                }
                            }
                            //console.log(this.optionnews,"optionsnews====")
                            this.optionnews=optionsss;
                        }else{
                            let option_=this.selectData[this.dataSource];
                            if(option_.length>0){
                                let empty={};
                            

                                for(let key in option_[0]){
                                    empty[key]="";
                                }
                                option_.unshift(empty)
                            }
                            
                            this.optionnews=option_
                        }
                        
                        if(this.isDefaultSelect=="Y"&&!this.currentValue&&this.optionnews.length>0){
                            //console.log("sssssssssss")
                            this.currentValue=this.optionnews[0].optvalue;
                        }else if(this.isDefaultSelect=="Y"&&this.optionnews.length>0&&!isOkss){
                            this.currentValue=this.optionnews[0].optvalue;
                        }
                        this.$emit("selectdata",JSON.stringify(this.optionnews));
                    }
                   
                   
                }
               
            },
            setSource(item){
                this.optionnews=item;
            },
            setData(){
                if(this.first!='Y'){
                    this.currentValueOld=this.currentValue;
                    this.first="N";
                }
                //console.log("isSearch=============="+this.isSearch+"=="+this.id)
                if(this.isSearch!='Y'){

                    if(!this.value){
                       // console.log("value=============="+this.value+"=="+this.index)
                        //console.log(this.data)
                        if(this.data){
                            let ids=this.id.split(".");
                            if(ids.length>1){
                                let p=ids[0];
                                let id_=ids[1];
                                this.pId=p;
                                this.cId=id_;
                               // console.log("pid====================="+p+"="+id_);
                                if(this.index||this.index=='0'){
                                    try{
                                        this.currentValue=unescape(this.data[p][this.index][id_]);
                                    }catch(e){}
                                }else{
                                    try{
                                        this.currentValue=unescape(this.data[p][id_]);
                                    }catch(e){}
                                }
                               // console.log(this.data);
                                
                            }else{
                                if(this.dataField){
                                    if(this.data[this.dataField][this.index][this.id])
                                        this.currentValue=unescape(this.data[this.dataField][this.index][this.id]);
                                }else{
                                    if(this.data[this.id])
                                        this.currentValue= unescape(this.data[this.id]);
                                }

                                
                                //console.log("curentValue===================================="+this.currentValue);
                            }
                        
                        }
                    }else{
                        
                        let data={};
                        data.id=this.id;
                        data.val=this.value;
                        data.index=this.index;
                        this.$emit('input',JSON.stringify(data));
                    }
                }else{
                    this.currentValue=unescape(this.data[this.index].vals)
                }
                if(this.first=="Y"){
                    this.oldValue=this.currentValue;
                    this.first="N";
                    if(this.exkey&&this.exkey.cascaderField){
                        this.currentValue2=this.data[this.pId][this.exkey.cascaderField].split(",")
                        console.log("this.currentValue2==================="+this.currentValue2+"=="+this.id)
                    }
                }
                
                if(this.extype=="show"){
                    for(let id in this.data.showOpr){
                        
                        let flag=this.data.showOpr[id];
                        //if(this.curentValue){
                            if(flag==this.currentValueOld){
                                this.data.show[id]="Y"
                            }
                            if(flag==this.currentValue){
                                this.data.show[id]='N'
                            }
                        //}else{
                        //    this.data.show[id]='N'
                       // }
                       
                    }
                    console.log(this.data.show,"shows=========================")
                    console.log(this.data.showOpr,"shows=========================")
                }
                /*console.log(this.id+"=="+this.isDefaultSelect+"=="+this.currentValue+"=="+this.optionnews.length)
                if(this.isDefaultSelect=="Y"&&!this.currentValue&&this.optionnews.length>0){
                    console.log("sssssssssss")
                    this.currentValue=this.optionnews[0].optvalue;
                }*/
               
                
               
                

               
            },
            changePosts(){
                if(this.exkey&&this.exkey.changePosts){
                    let url=this.exkey.changePosts.url;
                    let params=this.exkey.changePosts.params;
                    let paramss={};
                    let setData=this.exkey.changePosts.setData;

                    let isOk=true;
                    params.forEach(item=>{
                        let key =item.key;
                        let field=item.field.split(",");
                        let isEmpty=item.isEmpty;
                        let pre=item.pre;
                        let val="";
                        field.forEach(ff=>{
                        let val_= this.data[pre][ff]
                        val+=val_;
                        })
                        if(isEmpty=="N"&&!val){
                            isOk=false;
                        }
                        paramss[key]=val;
                    })
                    if(isOk){
                        this.$post("",url,paramss).then(data=>{
                            setData.forEach(item=>{
                                let dstField=item.dstField.split(".");
                                let srcField=item.srcField;
                                this.$set(this.data[dstField[0]],dstField[1],data[srcField]);
                            })
                        })
                    }
                }
            },
            changes(){
                console.log(this.exkey,"exkeychange=================")
                //try{ata
                    if(this.exkey&&this.exkey.changePost){
                        let paramData={}
                        if(this.exkey.changePost.params){
                            for(let key in this.exkey.changePost.params){
                                if(this.dataField){
                       
                                    let data_=this.data[this.dataField][this.index];
                                    paramData[key]=data_[this.exkey.changePost.params[key]]
                                }else{
                                    if(this.index=="0"||this.index){
                                      

                                        paramData[key]=this.data[this.pId][this.index][this.exkey.changePost.params[key]]
                                    }else
                                        paramData[key]=this.data[this.pId][this.exkey.changePost.params[key]]
                                    
                                }
                            }
                        }
                        this.$post("",this.exkey.changePost.post,paramData).then(data=>{
                            if(this.dataField){
                       
                                let data_=this.data[this.dataField][this.index];
                                for(let key in this.exkey.changePost.setData){
                                    data_[key]=data[this.exkey.changePost.setData[key]]
                                }
                                this.$set(this.data[this.dataField],this.index,data_)
                            }else{
                                if(this.index=="0"||this.index){
                                    let data_=this.data[this.pId][this.index];
                                    for(let key in this.exkey.changePost.setData){
                                        data_[key]=data[this.exkey.changePost.setData[key]]
                                    }
                                    this.$set(this.data[this.dataField],this.index,data_)
                                  
                                }else{
                                    for(let key in this.exkey.changePost.setData){
                                        this.$set(this.data[this.pId],key,data[this.exkey.changePost.setData[key]])
                                    }
                                }
                            }
                        })

                    }
                //}catch(e){}
            },
            handleChange(value){
                console.log(value,"handleChange=======")
                try{
                    if(value&&value.length>0){
                        this.currentValue=value[value.length-1]
                    }else{
                        this.currentValue="";
                    }
                }catch(e){}
                if(this.exkey.cascaderField){
                    this.$set(this.data[this.pId],this.exkey.cascaderField,value.join(","))
                }
                /*if(this.exkey&&this.exkey.setField){
                    for(let key in this.exkey.setField){

                    }
                }*/
                let nodes=this.$refs.myInputs.getCheckedNodes();

                let d=nodes[0].data;

                if(this.exkey&&this.exkey.setField){
                    for(let field in this.exkey.setField){
                        this.$set(this.data[this.pId],field,d[this.exkey.setField[field]])
                    }
                }
                //let label=nodes[0].data.label.split("-");
                //this.$set(this.data[this.pId],"scr_ex1",label[1])
                console.log(this.$refs.myInputs.getCheckedNodes(),"getCheckedNodes===============")
               // this.currentValue2=this.currentValue;
            }
        },
        computed:{
            
            dataFields:function(){
                if(this.pId&&this.index!="0"&&!this.index)
                    return this.data[this.pId][this.cId];
                else if(this.dataField){
                    return this.data[this.dataField][this.index];
                }else if((this.index=="0"||this.index)&&this.isSearch!='Y'){
                    let ids=this.id.split(".");
                    console.log("pId===="+this.pId+"=="+this.index+"=="+this.cId+"=="+this.id)
                    return this.data[ids[0]][this.index][ids[1]];
                }
                
            }
        },
        watch:{
            currentValue2:function(val){
                console.log("currentValue2=====================================")
                if(!val){
                    this.currentValue="";
                }
            },
            currentValue: function (val,oldval) { //currentValue值变动就向父组件传值
                console.log("selectWatch=-======================"+val+"="+oldval+"=="+this.oldValue)
                if(!val){
                    val="";
                }
                
                if(this.oldValue==val){
                    return;
                }
                console.log("ssssssssssssssssssssssssssssssssssssssssss")
                this.currentValue=filterXSS(this.currentValue,this.xssOption);
                this.currentValue=this.currentValue.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/%3C/g,"&lt;").replace(/%3E/g,"&gt;")
                 this.GLOBAL.isChange=true;
                this.currentValueOld=oldval;
                if(this.isChange=="Y"){
                     let label="";
                    for(let i=0;i<this.optionnews.length;i++){
                        if(this.optionnews[i].optvalue==val){
                            label=this.optionnews[i].optname;
                        }
                    }
                    let data={};
                    data.id=this.id;
                    data.val=val;
                    data.index=this.index;
                    data.label=label
                    this.$emit('input',JSON.stringify(data));
                }
                let exParams={}
                console.log("this.isSearch==========="+this.isSearch);
                if(this.isSearch!='Y'){
                    
                 //   console.log("111111111111111111111==="+this.dataField+"=="+this.index+"=="+val+"="+this.id)
                    if(this.dataField){
                       
                        let data_=this.data[this.dataField][this.index];
                        data_[this.id]=val;
                        this.$set(this.data[this.dataField],this.index,data_);
                    }else{
                        if(this.index=="0"||this.index){
                           // console.log("this.data====="+this.pId+"=="+this.index+"=="+this.cId+"=="+val+"=="+this.id+"=="+this.data[this.pId].length)
                            this.$set(this.data[this.pId][this.index],this.cId,val)
                        }else
                            this.$set(this.data[this.pId],this.cId,val)
                    }
                    
                    //this.extye==show代表这个下拉框要控制一些元素显示和隐藏，等于Y就是隐藏
                    if(this.extype=="show"){
                        for(let id in this.data.showOpr){
                        
                            let flag=this.data.showOpr[id];
                            if((","+flag+",").indexOf(","+this.currentValueOld+",")!=-1){
                                this.data.show[id]="Y"
                            }
                            if((","+flag+",").indexOf(","+this.currentValue+",")!=-1){
                                this.data.show[id]='N'
                            }
                        }
                    }
                 
                    console.log(this.exkey,"exkeyssss=====ss==11")
                    if(this.exkey){
                      
                      //  console.log("exkey-----"+this.exkey);
                      //  console.log(this.exkey);
                        let obj=null;
                      
                        try{
                            for(let i=0;i<this.optionnews.length;i++){
                                let optvalue=this.optionnews[i].optvalue;
                                if(optvalue==this.currentValue){
                                    obj=this.optionnews[i];
                                }
                            }
                        }catch(e){}
                        
                       // console.log("dddddddddddddddddddddddddddddd")
                        let exkeys=this.exkey;
                        try{
                            exkeys=exkeys.replace(/'/g,"\"");
                             exkeys=JSON.parse(exkeys);
                        }catch(e){}
                        //根据选择的值，给其他字段赋值
                        for(let key in exkeys){
                            try{
                                if(key!="label"&&key!="dataSource"&&key!="changePost"&&key!="setDate"&&key!='selectType'&&key!='setField'&&key!='cascaderField'){
                                    let v=exkeys[key];
                                    if(obj[v])
                                    exParams[key]=obj[v]
                               // console.log("this.dataField========"+this.index+"="+this.dataField+"="+key+"="+v+"=="+obj[v])
                                
                                    if(this.index=="0"||this.index){
                                      //  console.log(this.data[this.dataField][this.index])
                                        this.$set(this.data[this.dataField][this.index],key,obj[v])
                                    }else{
                                        this.$set(this.data[this.pId],key,obj[v])
                                    }
                                    

                                }
                            }catch(e){}
                            
                        }
                       
                        if(this.sessionSelect=="all"){
                            if(obj){
                                for(let key in obj){
                                    console.log("key3=="+key+"=pId=="+this.pId+"=index="+this.index+"=obj="+obj[key])
                                    this.$set(this.data[this.dataField][this.index],key,obj[key])
                                }
                            }
                        }
                     
                    }
                    console.log("changtes===")
                    this.changes();
                    this.changePosts();
                }else{
                    this.$set(this.data[this.index],"vals",val);
                    this.$emit("goSearch","")
                }
             
                this.oldValue=val;
                try{
                   // alert(this.exkey.label+"="+this.pId+"="+this.index)
                    if(this.exkey.label){
                        let label="";
                        for(let i=0;i<this.optionnews.length;i++){
                            if(this.optionnews[i].optvalue==val){
                                label=this.optionnews[i].optname;
                            }
                        }
                        if(this.index=="0"||this.index){
                            let pId=this.pId;
                            if(!pId){
                                pId=this.dataField;
                            }
                            this.$set(this.data[pId][this.index],this.exkey.label,label)
                        }else
                            this.$set(this.data[this.pId],this.exkey.label,label)
                        
                        
                    }
                }catch(e){}
                //选择后，重新读取数据
                if(this.paramKey){
                    let params={};
                    params.paramKey=this.paramKey;
                    params.params=this.currentValue;
                    
                    params.exParams=exParams;
                    params.id=this.id;
                    this.$parent.$parent.$parent.$parent.$parent.$parent.loadDataParam(params)
                }
                //赋值，把一个字段的值赋给另外一个字段
                if(this.setDatas){
                    console.log(this.setDatas,"this.setData")
                    for(let i=0;i<this.setDatas.length;i++){
                        let scrField=this.setDatas[i].scrField.split(".");
                        let dstField=this.setDatas[i].dstField.split(".");
                        let condition=this.setDatas[i].condition;
                        let sets=true;
                        if(condition){
                            for(let j=0;j<condition.length;j++){
                                let field=condition[j].field.split(".");
                                let opr=condition[j].opr;
                                let val=condition[j].val;
                                let val_=this.data[field[0]][field[1]]
                                if(opr=="等于"&&val!=val_){
                                    sets=false;
                                }
                                if(opr=="不等于"&&val==val_){
                                    sets=false;
                                }
                            }
                        }
                        if(sets){
                            this.$set(this.data[dstField[0]],dstField[1],this.data[scrField[0]][scrField[1]])
                        }
                    }
                }
                if(this.extype=="amt"){
                    /*if(!this.isRealNum(val)){
                        this.currentValue="";
                    }*/
                    let exkeys=this.amtStr.split(",");
                    
                    let val_=Number(val);
                    let val2_=Number(this.data[this.pId][exkeys[0]]);
                    this.$set(this.data[this.pId],exkeys[1],val_*val2_);
                }
            },
            value:function (val) { //对值进行验证
                
            },
            options:function(val){
                this.optionnews=val;
            },
            dataFields:{
                handler: function (newVal) {
                    this.setData();
                    if(this.changeId.length>0){
                        let isChange=false;
                        if(this.index=="0"||this.index){
                            for(let key in this.changeId){
                                if(this.data[this.pId][this.index][key]!=this.changeId[key]){
                                    isChange=true;
                                }
                            }
                        }else{
                            for(let key in this.changeId){
                                if(this.data[this.pId][key]!=this.changeId[key]){
                                    isChange=true;
                                }
                            }
                        }
                        
                        if(isChange){
                            this.getSelect();
                        }
                    }
                    
                },      
                deep: true    //深度监听
            },
            data:{
                handler: function (newVal) {
                    if(this.changeId){
                        let isChange=false;

                        if(this.index=="0"||this.index){
                             for(let key in this.changeId){
                                if(this.data[this.dataField][this.index][key]!=this.changeId[key]){
                                    isChange=true;
                                    this.changeId[key]=this.data[this.dataField][this.index][key]
                                }
                            }
                        }else{
                             for(let key in this.changeId){
                                if(this.data[this.pId][key]!=this.changeId[key]){
                                    isChange=true;
                                    this.changeId[key]=this.data[this.pId][key]
                                }
                            }
                        }
                        if(isChange){
                            this.getSelect();
                        }
                    }
                },
                deep:true
            }
        }
    }
</script>
<style scoped>
.isEdits{
    left:0;
    
}
.no-border>>>.el-select {
    border: 0;
  }
.no-border{
    border:0 !important;
}
.myselect{
    position:relative;
    width:100%;
}

.myInput{
    position:absolute;
    width: calc(100% - 25px);
    border-right:0;
}
.myInput >>> .el-input__inner{
     border-right:0;
}
</style>